package io.sk.controller;


import io.sk.common.base.BaseController;
import io.sk.common.base.BaseResult;
import io.sk.common.base.Constants;
import io.sk.entity.ChildEntity;
import io.sk.service.ChildService;
import io.sk.vo.ReviewSearchVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 班级信息
 *
 * @author xubinren
 * @version 1.0
 * @date 2018/5/8 18:04
 */
@RestController
@RequestMapping("child")
@Api(tags = "孩子接口")
public class ChildController extends BaseController {

    @Autowired
    private ChildService childService;

    /**
     * 申请加入班级
     *
     * @param child  参数信息
     * @param avatar 头像
     * @return BaseResult
     */
    @PostMapping("/save")
    @ApiOperation("加入班级")
    public BaseResult save(ChildEntity child, String avatar) {

        //参数验证
        if (null == child) {
            return sendResult400();
        }
        return childService.save(child, avatar.trim());
    }

    /**
     * 分页查询审核列表
     *
     * @param reviewSearchVo 查询条件
     * @return BaseResult
     */
    @PostMapping("/reviewPage")
    @ApiOperation("分页查询审核列表")
    public BaseResult reviewPage(ReviewSearchVo reviewSearchVo/*, PageUtils page*/) {

        //数据验证
        if (StringUtils.isEmpty(reviewSearchVo.getId())) {
            return sendResult400();
        }

        return childService.reviewPage(reviewSearchVo);
    }

}
